package gameObjects;

import java.net.URL;

import com.jme.image.Texture;
import com.jme.image.Texture.MagnificationFilter;
import com.jme.image.Texture.MinificationFilter;
import com.jme.scene.Node;
import com.jme.scene.Skybox;
import com.jme.util.TextureManager;

public class Sky {
	private static Sky 	sky;
	
	public static Sky getInstance()
	{
		if(sky==null)
			sky = new Sky();
		return sky;
	}
	
	public Node create()
    {
    	Node skyNode=new Node();
    	Skybox skyBox;
    	
    	URL url = Sky.class.getClassLoader().getResource("textures/space.jpg");
    	Texture skyTex = TextureManager.loadTexture(url,
	    		MinificationFilter.Trilinear, 
	    		MagnificationFilter.Bilinear);   
    	skyBox = new Skybox("SKY",600f,600f,600f);
    	skyBox.setTexture(Skybox.Face.Down, skyTex);
    	skyBox.setTexture(Skybox.Face.Up, skyTex);
    	skyBox.setTexture(Skybox.Face.East, skyTex);
    	skyBox.setTexture(Skybox.Face.North, skyTex);
    	skyBox.setTexture(Skybox.Face.South, skyTex);
    	skyBox.setTexture(Skybox.Face.West, skyTex);

    	skyNode.attachChild(skyBox);
    	
    	return skyNode;
    }
}
